# Maintainer: J. Peter Mugaas <jpmugaas@suddenlink.net>

pkgbase=python-pytest
pkgname=('python2-pytest')
pkgver=4.6.4
pkgrel=1
pkgdesc="Simple powerful testing with Python"
arch=('any')
license=('MIT')
url="https://pytest.org/"
depends=('python2'
         'python2-atomicwrites'
         'python2-attrs'
         'python2-more-itertools'
         'python2-pluggy'
         'python2-py'
         'python2-setuptools'
         'python2-six')
makedepends=('python2-setuptools-scm')
source=("pytest-${pkgver}.tar.gz::https://github.com/pytest-dev/pytest/archive/${pkgver}.tar.gz")
sha512sums=('58eed6f9e367b23944805eb10f1d727e95a8e42f65fbef673b890656a6395746aee5d0891a0849d2bfa5bb46fafda6120bb1d0b532b0d95586bb196942395dd0')

prepare() {
  sed -i "s/'_pytest.vendored_packages'//" pytest-${pkgver}/setup.py
  sed -i 's/assert numentries == 0/assert numentries == 26/' pytest-${pkgver}/testing/python/collect.py
  cp -a pytest-${pkgver}{,-py2}
}

build() {
  export SETUPTOOLS_SCM_PRETEND_VERSION=${pkgver}

  cd "${srcdir}/pytest-${pkgver}-py2"
  python2 setup.py build
}

package() {
  cd pytest-${pkgver}-py2
  python2 setup.py install --root="${pkgdir}" --optimize=1 --skip-build
  install -D -m644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"

  for f in {py.test,pytest}; do
    mv "${pkgdir}"/usr/bin/${f}{,2}
  done
}

